
<?php
$sec = $vars['sec'];
$highstock_baseurl = elgg_get_site_url()."mod/xray/vendor/highstock/";

$sec_name = get_securities_name_by_code($sec);

$fund = $vars['fund_id'];
//print_r('sec=' . $sec);
//print_r('fund_id=' . $fund);

?>

		<script type="text/javascript">
$(function() {
	$.getJSON('<?php echo elgg_get_site_url()."xray/data/$sec?fund_id=$fund&"; ?>callback=?', function(data) {
	
		// split the data set into ohlc and volume
		var ohlc = [],
			volume = [],
			dataLength = data.length;
			
		for (i = 0; i < dataLength; i++) {
			ohlc.push([
				data[i][0], // the date
				data[i][1], // open
				//data[i][2], // high
				//data[i][3], // low
				//data[i][4] // close
			]);
			
			volume.push([
				data[i][0], // the date
				data[i][2], // the volume
				data[i][3], // the comment    
			])
		}

		// set the allowed units for data grouping
		var groupingUnits = [[
			'day',                         // unit name
			[1]                             // allowed multiples
		]/*, [
			'month',
			[1, 2, 3, 4, 6]
		]*/];

		// create the chart
		chart = new Highcharts.StockChart({
		    chart: {
		        renderTo: 'container',
		        alignTicks: false
		    },

		    tooltip: {
		        //enabled: false,
		        //shadow: false
		        shared: false,
				crosshairs: [true, true]
		    },

		    rangeSelector: {
		        selected: 1
		    },

		    title: {
		        text: '<?php echo "$sec $sec_name";?>'
		    },

		    yAxis: [{
		        title: {
		            text: 'Stock Price'
		        },
		        height: 200,
		        lineWidth: 2
		    }, {
		        title: {
		            text: 'Volume'
		        },
		        top: 300,
		        height: 100,
		        offset: 0,
		        lineWidth: 2
		    }],
		    
		    series: [{
		        //type: 'areaspline',
		        name: 'Close Price',
		        data: ohlc,
		        dataGrouping: {
					units: groupingUnits
		        },
				id : 'dataseries',
				//noSharedTooltip : true
		    }, {
		        type: 'column',
		        name: 'Exec Amt',
		        data: volume,
		        yAxis: 1,
		        dataGrouping: {
					units: groupingUnits
		        },
				id : 'columnseries',
				//noSharedTooltip : true
			},
			// the event marker flags
			{
				<?php echo elgg_view('stockblogs', $vars); ?>				
				/*type : 'flags',
				data : [{
					x : 1332460800000,//Date.UTC(2011, 3, 28),
					title : '3G4',
					text : 'EURUSD: Bulls Clear Path to 1.50 Figure'
				}, {
					x : 1335139200000,//Date.UTC(2011, 3, 25),
					title : 'LMQ <a href="http://www.baidu.com" target="_blank">blog title here?</a>',
					text : '<a href="http://www.baidu.com" target="_blank">Euro Contained by Channel Resistance</a>'
				}, {
					x : 1335139200000,//Date.UTC(2011, 3, 25),
					title : '123123',
					text : '123123'
				}, {
					x : 1333584000000,//Date.UTC(2011, 3, 28),
					title : '5F6',
					text : 'EURUSD: Rate Decision to End Standstill'
				}],
				onSeries : 'dataseries',
				shape : 'circlepin',
				//shape : 'squarepin',
				width : 16*/
		    }, {
				<?php echo elgg_view('stocktrades', $vars); ?>				
		        /*type: 'flags',
		        name: 'Flags on column',
		        data: [{
					x: 1331164800000,//Date.UTC(2011, 2, 1),
					title: 'On column',
					text : 'asdfasdfasdfa'
				}, {
					x: 1334016000000,//Date.UTC(2011, 3, 1),
					title: 'On column',
					text : '12312312312'
				}],
		        yAxis: 1,
				onSeries : 'columnseries',
		        shape: 'squarepin',
				width : 6*/
		    }, {
		        /*type: 'flags',
		        name: 'Flags on axis',
		        data: [{
					x: 1331164800000,//Date.UTC(2011, 3, 1),
					title: 'On axis',
					text : '12'
				}, {
					x: 1334016000000,//Date.UTC(2011, 3, 1),
					title: 'On axis',
					text : '21'
				}],
		        shape: 'squarepin',
				width : 6*/
		    }]
		});
	});
});

		</script>

<script src="<?php echo $highstock_baseurl; ?>js/highstock.src.js"></script>

<div id="container" style="height: 500px; min-width: 500px"></div>
